import cv2
import mediapipe as mp
import time
class HandDetector:
init (self, mode=False, max hands=2, model com=l, detection con=0.5, track con=0.5):
def
self.mode = mode
self.maxHands = max hands
self.model com = model com
self detectionCon=detection con
self.trackCon =track con
self.results=0
self.mpHands = mp.solutions.hands
self.hands = self.mpHands.Hands(self.mode, self.maxHands, self.model com
self,detectionCon, self.trackCon)
self.mpDraw =mp.solutions.drawing utils
def find hands(self, img, draw=True):
img rgb = cv2.cvtColor(img, cv2.COLOR BGR2RGB)
self.results =self.hands.process(img rgb)
if self,results,multi hand landmarks:
for handLms in self.results.multi hand landmarks:
if draw:
self.mpDraw.draw landmarks(img, handLms,
self.mpHandS.HAND CONNECTIONS)
return img